Skip to content

Add element array#57

Merged
JeanLucPons merged 9 commits intomainfrom
add-element-array
Nov 6, 2025
Merged

Add element array#57
JeanLucPons merged 9 commits intomainfrom
add-element-array

Conversation

@JeanLucPons
Copy link
Copy Markdown
Contributor

@JeanLucPons JeanLucPons commented Nov 5, 2025

This PR adds ElementArray and fix few array bugs. This is a step toward the @GamelinAl requirements.

CombinedFunctionManget has been removed from the ElementHolder. It was wrong because unattached CFM was added for nothing. Handling of attached CFM will be done later (if needed)
Virtual magnets work as before.

It is now possible to write:
(Element are in the creation order)

    # Create an array that contains all elements
    allElts = ElementArray("AllElements",sr.design.get_all_elements())    
    assert(len(allElts)==9)

    # Create an array that contains all elements
    allMags = MagnetArray("AllMagnets",sr.design.get_all_magnets())    
    assert(len(allMags)==7)

    # Create an array that contains all BPM
    allBpms = BPMArray("AllBPMs",sr.design.get_all_bpms())    
    assert(len(allBpms)==2)

@JeanLucPons
Copy link
Copy Markdown
Contributor Author

JeanLucPons commented Nov 5, 2025

I added a function in the Factory that should be able to do the same thing than the previous buggy ElementHolder.get_all_magnets() function. It returns unattached Magnets from the Factory.
Hope it can help.

from pyaml.configuration.factory import Factory
from pyaml.magnet.magnet import Magnet
from pyaml.magnet.cfm_magnet import CombinedFunctionMagnet
...
mags = Factory.get_elements_by_type((Magnet,CombinedFunctionMagnet))

@JeanLucPons
Copy link
Copy Markdown
Contributor Author

I added CombinedFunctionMagnetArray.
Aggregator for this array still need to be implemented.
Please keep in mind that for pyAML a CombinedFunctionMagnet is not a Magnet (SingleFunctionMagnet).
However a CombinedFunctionMagnet is an Element so it can also be added to ElementArray.

Example:

      - type: pyaml.arrays.cfm_magnet
        name: CFM
        elements:
          - SH1A-C01
          - SH1A-C02

Copy link
Copy Markdown
Contributor

@gupichon gupichon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems ok to me. It needs more examples on how it should be properly used.

@JeanLucPons JeanLucPons merged commit 526615d into main Nov 6, 2025
2 checks passed
@gubaidulinvadim gubaidulinvadim deleted the add-element-array branch December 17, 2025 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants